/*
 * @Date: 2024-09-18 10:03:07
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2024-09-18 17:06:50
 * @Description: 图标的相关配置
 */

import defaultIconfont from  '@/assets/iconfont/default/iconfont.json';

import * as eleIconfonts from '@element-plus/icons-vue';

/**
 * 获取阿里图标
 */
export const getAliIconfont = () => {
  let iconfontList = []
  for (let iconItem of defaultIconfont.glyphs) {
    iconfontList.push({
      name: `${defaultIconfont.css_prefix_text}${iconItem.font_class}`,
      family: defaultIconfont.font_family,
      prefix: defaultIconfont.css_prefix_text,
      fontClass: `${defaultIconfont.css_prefix_text}${iconItem.font_class}`
    })
  }
  return iconfontList
}

/**
 * 获取Element UI的图标
 * 
 * @returns 图标数据集
 */
export const getEleIconfont = () => {
  let elPix = 'el-'
  let iconfontList = []
  for (let index in eleIconfonts) {
    let iconName = eleIconfonts[index].name
    iconfontList.push({
      name: `${elPix}${iconName}`,
      family: elPix,
      prefix: elPix,
      fontClass: `${elPix}${iconName}`
    })
  }
  return iconfontList
}

const iconfontSheet = {
  ali: () => {
    return getAliIconfont()
  },
  ele: () => {
    return getEleIconfont()
  }
}

export default iconfontSheet